package client.comm.baoding.ui

import android.content.Intent
import client.comm.commlib.toast.toast
import client.comm.baoding.R
import client.comm.baoding.databinding.ActivityCreaterechargeBinding
import client.comm.baoding.ui.vm.CreateRechargeViewModel
import client.comm.baoding.BaseMiddleActivity
class CreateRechargeActivity :
    BaseMiddleActivity<CreateRechargeViewModel, ActivityCreaterechargeBinding>() {
    override fun getLayout(): Int {
        return R.layout.activity_createrecharge
    }

    override fun initViewModel(): CreateRechargeViewModel = createViewModel()

    override fun initView() {
        binding.event = this
        binding.vm = viewModel
    }

    override fun initData() {
//        viewModel.callUserInfo()
    }

    override fun observerUI() {
        viewModel.okCall.observe(this, {
            it?.let {
                if (it.isSuccess) {
                    startActivity(Intent(this, RechargeActivity::class.java))
                    finish()
                } else {
//                    toast(it.message)
                }
            }
        })
    }

    fun ok() {
        if (viewModel.num.value == null || viewModel.txType.value!! < 0) {
            toast("所有不得为空")
            return
        }
        viewModel.ok()
    }

    fun goRecord() {
        startActivity(Intent(this, RechargeRecordActivity::class.java))
    }
}